﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FileCopyer
{
    internal class GlobalConfig
    {
        private static GlobalConfig instance;

        public static GlobalConfig Instance
        {
            get
            {
                if(instance == null)
                {
                    instance = new GlobalConfig();
                    instance.Load();
                }
                return instance;
            }
        }

        public string CesiumFilePath { get; set; } = @"E:\AgCIMBarium\cesium-main\";
        public string BariumFileName { get; set; } = @"E:\AgCIMBarium\Barium\agcim.barium\";

        public string NewSaveFilePath { get; set; }

        public void Save()
        {
            File.WriteAllLines("config.txt", new string[]
           {
                CesiumFilePath, BariumFileName,NewSaveFilePath
           });
        }

        public void Load()
        {
            if (File.Exists("config.txt"))
            {
                var lines = File.ReadAllLines("config.txt");
                CesiumFilePath = lines[0].Trim();
                BariumFileName = lines[1].Trim();
                NewSaveFilePath = lines.Length > 2 ? lines[2].Trim() : NewSaveFilePath;
            }
        }
    }
}
